<template>
  <div class="app-container">
    <logs-filter @on-filter="submitFilterForm"/>
    <el-table :data="tableData.list" v-loading="loading" element-loading-text="加载中...">
      <el-table-column label="账户类型" prop="userType">
        <template slot-scope="{row}">
          {{row.userType | toConverter('ACCOUNT_TYPE')}}
        </template>
      </el-table-column>
      <el-table-column label="账户名" prop="username">
      </el-table-column>
      <el-table-column label="银行名称" prop="bankName">
      </el-table-column>
      <el-table-column label="银行支行" prop="address">
      </el-table-column>
      <el-table-column label="银行卡号" prop="cardNo">
      </el-table-column>
      <el-table-column label="状态" prop="status">
        <template slot-scope="{row}">
          {{row.status | toConverter('BANK_STATUS')}}
        </template>
      </el-table-column>
      <el-table-column label="时间">
        <el-table-column label="新增时间">
          <template slot-scope="{row}">
            {{row.createDate | toTime}}
          </template>
        </el-table-column>
        <el-table-column label="删除时间">
          <template slot-scope="{row}">
            <span v-if="row.status === 1">
            {{ row.lastUpdate | toTime}}
            </span>
            <span v-else>
              ---
            </span>
          </template>
        </el-table-column>
      </el-table-column>
    </el-table>

    <div class="pagination-container">
      <el-pagination background @size-change="gridSizeChange" @current-change="gridCurrentChange"
                     :current-page="filters.page" :page-sizes="gridPageSize" :page-size="filters.size"
                     :layout="gridLayout" :total="tableData.total">
      </el-pagination>
    </div>
  </div>
</template>


<script>
  import { getBankLogs} from '@/services/api/banks';
  import {grid} from '@/build'
  import logsFilter from './filter'

  export default {
    name: "finance-user-bank-logs",
    components: {logsFilter},
    mixins:[grid],
    data() {
      return {
        tableData: {},
        rowData:{},
        auditDialogVisible: false,
        filters: {
          page:1,
          size: 20,
          dateType: 0,
          startDate:moment().format('YYYY-MM-DD 00:00:00'),
          endDate:moment().format('YYYY-MM-DD 23:59:59'),
        },
        filterDateType: false,
      }
    },
    methods:{
      showAuditDialog(row,step){
        this.auditDialogVisible = true
        this.rowData = row
        this.auditStep = step
      },
      submitFilterForm(formInline) {
        const {time} = formInline;
        let startDate= undefined, endDate= undefined;
        if(!_.isUndefined(time) && _.isArray(time)){
          startDate= time[0];
          endDate= time[1];
          formInline = {...formInline,startDate,endDate}
        }else{
          this.filters.startDate = undefined;
          this.filters.endDate = undefined;
        }
        this.filters = {...this.filters,...formInline}
        this.gridSearch();
      },
    },
    mounted(){
      this.bindGet(getBankLogs, 'tableData', {
        action: 'getGrid',
        sendingData: 'filters'
      });
      this.getAll()

    }
  }
</script>

<style scoped>

</style>
